<?php

/*
*
* BEGIN liveMatch.php
*
*
* Dazzler Live Match - Presenter Layer
* @Description: Presents the live match page
* @Authors: Salman Noor, Wits University
* @Copyright: © Wits University 2011 - All Rights Reserved
* @License: BSD License (http://www.linfo.org/bsdlicense.html)
*
*
* BEGIN CHANGELOG
* Developers working on thee files are REQUIRED to maintain this CHANGELOG.
* Please ensure you follow the Changelog Guidelines: http://code.google.com/p/dazzler/wiki/DazzlerDevelopGuideline?ts=1315476570&updated=DazzlerDevelopGuideline
* !==================================================================================================================================================================
*
* VERSION 1.0.0
*	+ File Created, Salman, 5 October 2011
*
* ==================================================================================================================================================================!
* END CHANGELOG
*/


/*******************************************************************************************************************************************************************
*
* BEGIN Direct Call Check
*
/******************************************************************************************************************************************************************/
global $doNotCallThisScriptDirectly;
if ($doNotCallThisScriptDirectly != 1)
{
	/* Read the ini language file */
	$ini_lang_array = array();
	$clientlang = explode(",", strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']));
	$lang_ini_array = (file_exists("lang/" . trim($clientlang[0]) . ".ini")) ? parse_ini_file("lang/" . trim($clientlang[0]) . ".ini", true) : parse_ini_file("lang/en.ini", true);
	die ($lang_ini_array['ERRORS']['doNotCallThisScriptDirectly']);
}
/*******************************************************************************************************************************************************************
*
* END Direct Call Check
*
/******************************************************************************************************************************************************************/


$uri_array = explode("/", $_SERVER['REQUEST_URI']);
$GameID =  $uri_array[3];


$homeTeamLogo= NULL;
$awayTeamLogo= NULL;
$css_head = NULL;
$js_head = NULL;
$modalWindowContent = NULL;
$ScoreCardContent = NULL;


$cm = new fetchpathitems($path . "/sites/dazzler/themes/$loadType/custom/styles/livematch", "css");

foreach($cm->cm as $includeCssFile)
{
    $css_head .= "<link rel='stylesheet' type='text/css' href='$rootpath/themes/$loadType/custom/styles/livematch/$includeCssFile' />";
}

$cm = new fetchpathitems($path . "/sites/dazzler/themes/$loadType/global/scripts", "js");

foreach($cm->cm as $includeJsFile)
{
        $js_head .= "<script src='$rootpath/themes/$loadType/global/scripts/$includeJsFile'></script>\n";
}

$cm = new fetchpathitems($path . "/sites/dazzler/themes/$loadType/custom/scripts/livematch", "js");

foreach($cm->cm as $includeJsFile)
{
        $js_head .= "<script src='$rootpath/themes/$loadType/custom/scripts/livematch/$includeJsFile'></script>\n";
}

$hiddenInput = new htmlcodemaker('input');
$hiddenInput->set(array('id'=>'gameID','name'=>'gameID','type'=>'hidden','value'=>$GameID));

$GameAdmin = new GameAdmin();
$awayTeamDetailsArray = $GameAdmin->getAwayTeam($GameID);
$homeTeamDetailsArray = $GameAdmin->getHomeTeam($GameID);

$homeTeamShortName = strtolower($homeTeamDetailsArray['TEAM_POOL_SNAME']);
$awayTeamShortName = strtolower($awayTeamDetailsArray['TEAM_POOL_SNAME']);
$homeTeamLogo = "teambanners home_"."$homeTeamShortName";
$awayTeamLogo = "teambanners away_"."$awayTeamShortName";
$GameDetailsArray = $GameAdmin->getGameDetails($GameID);
$GameTitle = null;
$GameType = null;
$GameVenue = null;

foreach($GameDetailsArray as $gameDetails)
{
$GameTitle = $gameDetails['GAME_TIT'];
$GameType = $gameDetails['GAME_TYPE'];

$GameVenue = $gameDetails['GAME_VEN'];
break;
}

$MatchDescription = $GameTitle." (".$GameType.")";
$hiddenAwayTeamInput = new htmlcodemaker('input');
$hiddenAwayTeamInput->set(array('id'=>'awayTeamName','name'=>'awayTeamName','type'=>'hidden','value'=>$awayTeamDetailsArray['TEAM_POOL_NAME']));

$hiddenHomeTeamInput = new htmlcodemaker('input');
$hiddenHomeTeamInput->set(array('id'=>'homeTeamName','name'=>'homeTeamName','type'=>'hidden','value'=>$homeTeamDetailsArray['TEAM_POOL_NAME']));

$loadingImagePath = "$rootpath/themes/$loadType/global/images/loading.gif";
$hiddenLoadingImage = "<input type='hidden' id='loadingImage' name='loading Image Path' value=$loadingImagePath />";

//echo $GameID;
//$StatsAdmin = new StatsAdmin();
//var_dump($GameID);
//$a = $StatsAdmin->getFullBowlingScoreCard($GameID, 1);
//$a = $StatsAdmin->getSummaryBattingScoreCard($GameID, 1);
//$GameID = "15";
//$a = $StatsAdmin->getFullBattingScoreCard($GameID, 1);
//r u checjing$a = $StatsAdmin->stillToBat($GameID,1);
//$a = $StatsAdmin->getBarGraphData($GameID, 1);
//$a = $StatsAdmin->getManhattanData($GameID, 1);
//$a = $StatsAdmin->getFallOfWickets("15", 1);
//print_r($a);
//print_r($a);

$StatsAdmin = new StatsAdmin();
$innings = $StatsAdmin->getInnings($GameID);
$full_scorecard_ui = new full_scorecard_ui($GameID, $innings);
$ScoreCardContent = "<div id='fullBattingScoreCardContainer'>".$full_scorecard_ui->showFullBattingScoreCard()."</div>";
$ScoreCardContent .= "<div id='fullBowlingScoreCardContainer'>".$full_scorecard_ui->showFullBowlingScoreCard()."</div>";
$ScoreCardContent .= "<div id='fallOfWicketsContainer'>".$full_scorecard_ui->showFallofWickets()."</div>";
$ScoreCardContent .= "<div class='loadingScreenTabContainer'></div>";
$MatchStatsContent = NULL;

//$MatchStatsContent .= "<div id='wormContainerSecondInnings'style='float:left; clear:right; width: 700px; height: 400px; padding:10px; margin: 10px'></div>";
//$MatchStatsContent .= "<span id='chartcontainers' style='float:left;'>";

$MatchStatsContent .= "<div id='manhattanContainerFirstInnings' style='float:left; clear:left; width: 700px; height: 400px; padding:10px; margin: 10px'></div>";

$MatchStatsContent .= "<div id='manhattanContainerSecondInnings' style='float:left; clear:right; width: 700px; height: 400px; padding:10px; margin: 10px'></div>";

$MatchStatsContent .= "<div id='runsTypeContainerFirstInnings' style='float:left; clear:left; width: 700px; height: 400px; padding:10px; margin: 10px'></div>";
$MatchStatsContent .= "<div id='runsTypeContainerSecondInnings' style='float:left; clear:right; width: 700px; height: 400px; padding:10px; margin: 10px'></div>";
$MatchStatsContent .= "<div id='wormContainer'style='float:left; width:1000px; height: 550px; margin:30px 200px 200px 200px;'></div>";
//$MatchStatsContent .= "</span>";


$liveViewContent = NULL;
$live_view_ui = new live_view_ui($GameID, 1);
$liveViewContent .= $live_view_ui->getWagonWheel();
$liveViewContent .= $live_view_ui->showLiveViewDisplay();
$cornerImage = "$rootpath/themes/$loadType/global/images/corner_img.png";
include $path . "/sites/dazzler/themes/$loadType/templates/livematch.php";
?>

